fix(#248): ARM64 Linux auto-fallback to Firefox + --browser CLI flag#467
fix(#248): ARM64 Linux auto-fallback to Firefox + --browser CLI flag#467giulio-leone wants to merge 2 commits intovercel-labs:mainfrom
Conversation
|
@g97iulio1609 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
… flag - Auto-detect ARM64 Linux and fall back to Firefox when Chromium unavailable - Add --browser CLI flag to explicitly select browser engine - Pass AGENT_BROWSER_BROWSER env var through daemon - Emit warning when falling back to Firefox
1cfaf9c to
19e78a1
Compare
There was a problem hiding this comment.
Pull request overview
Adds browser selection support and an ARM64 Linux compatibility fallback so agent-browser can run on aarch64 where Playwright Chromium binaries may be unavailable.
Changes:
- Auto-fallback from Chromium to Firefox on ARM64 Linux (with a launch warning).
- Introduce a
--browserCLI flag and forward browser choice to the daemon via env var. - Wire daemon-side auto-launch to read the browser choice from environment.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/daemon.ts | Reads AGENT_BROWSER_BROWSER and forwards browser into auto-launch options. |
| src/browser.ts | Implements ARM64 Linux Chromium → Firefox fallback and warning collection. |
| cli/src/main.rs | Passes browser from parsed flags into daemon startup options. |
| cli/src/flags.rs | Adds browser and cli_browser fields; updates arg cleaning/config pre-parse lists. |
| cli/src/connection.rs | Forwards browser option to daemon via AGENT_BROWSER_BROWSER. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Auto-fallback to Firefox on ARM64 Linux where Chromium is unavailable | ||
| if (effectiveBrowser === 'chromium' && process.arch === 'arm64' && process.platform === 'linux') { | ||
| effectiveBrowser = 'firefox'; | ||
| this.launchWarnings.push('Chromium unavailable on ARM64 Linux; using Firefox instead'); |
There was a problem hiding this comment.
This fallback warning is only pushed into launchWarnings but (unlike other warnings in this method) it isn’t printed to stderr. As a result, users running the daemon directly (or any client that doesn’t surface data.warnings) may never see the warning. Consider also emitting it via console.error('[WARN] ...') for consistency with the other warnings above.
| this.launchWarnings.push('Chromium unavailable on ARM64 Linux; using Firefox instead'); | |
| const warning = 'Chromium unavailable on ARM64 Linux; using Firefox instead'; | |
| this.launchWarnings.push(warning); | |
| console.error(`[WARN] ${warning}`); |
| if let Some(b) = opts.browser { | ||
| cmd.env("AGENT_BROWSER_BROWSER", b); | ||
| } |
There was a problem hiding this comment.
PR description calls out an env var AGENT_BROWSER_BROWSER_BROWSER, but the implementation sets/reads AGENT_BROWSER_BROWSER. Please align the PR description (or the env var name) to avoid shipping misleading configuration docs.
| pub allowed_domains: Option<Vec<String>>, | ||
| pub action_policy: Option<String>, | ||
| pub confirm_actions: Option<String>, | ||
| pub confirm_interactive: bool, | ||
| pub browser: Option<String>, | ||
| pub cli_browser: bool, | ||
|
|
There was a problem hiding this comment.
browser / cli_browser fields were added to Flags, but parse_flags never initializes them in the Flags { ... } literal (so this won’t compile) and there is no match arm to parse the new --browser flag / AGENT_BROWSER_BROWSER env var into flags.browser. Please add the missing struct fields to the initializer and implement parsing (including setting cli_browser = true when --browser is provided).
|
|
||
| const ignoreHTTPSErrors = process.env.AGENT_BROWSER_IGNORE_HTTPS_ERRORS === '1'; | ||
| const allowFileAccess = process.env.AGENT_BROWSER_ALLOW_FILE_ACCESS === '1'; | ||
| const browserType = process.env.AGENT_BROWSER_BROWSER as 'chromium' | 'firefox' | 'webkit' | undefined; |
There was a problem hiding this comment.
process.env.AGENT_BROWSER_BROWSER as ... is a compile-time cast only; at runtime any string can flow through here. If the env var is set to an unexpected value (typo, casing, etc.) it will silently behave as Chromium later. Please validate the value against the allowed set ('chromium' | 'firefox' | 'webkit') and either ignore it with a warning or return an error.
| const browserType = process.env.AGENT_BROWSER_BROWSER as 'chromium' | 'firefox' | 'webkit' | undefined; | |
| const browserEnv = process.env.AGENT_BROWSER_BROWSER; | |
| let browserType: 'chromium' | 'firefox' | 'webkit' | undefined; | |
| if (browserEnv === 'chromium' || browserEnv === 'firefox' || browserEnv === 'webkit') { | |
| browserType = browserEnv; | |
| } else { | |
| if (browserEnv) { | |
| console.warn( | |
| `Invalid AGENT_BROWSER_BROWSER value "${browserEnv}". Expected one of "chromium", "firefox", or "webkit"; falling back to default.` | |
| ); | |
| } | |
| browserType = undefined; | |
| } |
src/browser.ts
Outdated
| // Auto-fallback to Firefox on ARM64 Linux where Chromium is unavailable | ||
| if (effectiveBrowser === 'chromium' && process.arch === 'arm64' && process.platform === 'linux') { |
There was a problem hiding this comment.
Auto-fallback currently always forces Firefox on arm64 Linux even when the user may have a working Chromium via executablePath (or a future Playwright build adds support). Consider attempting the requested browser first and only falling back when launch fails with the specific “Chromium distribution not found”/unsupported-platform error, so arm64 users with a valid Chromium aren’t prevented from using it.
| // Auto-fallback to Firefox on ARM64 Linux where Chromium is unavailable | |
| if (effectiveBrowser === 'chromium' && process.arch === 'arm64' && process.platform === 'linux') { | |
| // Auto-fallback to Firefox on ARM64 Linux where the bundled Chromium is unavailable. | |
| // If the user has provided an explicit executablePath for Chromium, honor that choice. | |
| if ( | |
| effectiveBrowser === 'chromium' && | |
| process.arch === 'arm64' && | |
| process.platform === 'linux' && | |
| !options.executablePath | |
| ) { |
Closes #248
Problem
Chromium is not available for ARM64 Linux (aarch64). Playwright fails with 'Chromium distribution not found'.
Solution
chromiumis requested on ARM64 Linux, automatically use Firefox instead (with a warning)--browserflag: New CLI flag to explicitly choose browser engine (chromium,firefox,webkit)AGENT_BROWSER_BROWSERfor configurationUsage